require(["jquery","page","qs"],function($,page,qs){
    var myPage;
    initPage (1);
    function initPage (goPage){
        var url = "http://zxkt.dodoedu.com/api/getYanxiuList";
        var params = {
            classify:0,
            stage: 3,
            subject: 4,
            child: 0,
            tab:"",
            time:""
        };
        var str =  qs.stringify(params);
        var getData = str + "&page=1&page_count=8";
        page.getAjax(url,getData,function(obj){
            if(obj['errcode'] === 0){
                /*情况1第一次不加载  page.firstLoad = false;  */
                /*情况2第一次加载 ;*/
                // page.firstLoad = false;
                $("body").attr({"requestData": 0})
                var data = obj.data;
                var total = data.total ? data.total : 1;
                var length = data.list.length;
                myPage =  new page.jsPage(total,"pageNum",length,url,getData,buildTable,goPage,null);
                page.pageMethod.call(myPage);
            }else{
                // layer.msg(res.msg,{icon:5},{time:5000});
                console.log(obj.message);
            }
        });

        function buildTable(obj) {
            //console.log("buildTable",obj);
            var data = obj.data.list;
            var html = '';
            $.each(data,function (i,v) {
                html += ' <div class="item">\n' +
                    '                   <a href="yanxiu/info?id=595" target="_blank" class="a" style="background-image:url('+ v.activity_info_icon +')"></a>' +
                    '                   <div class="info">' +
                    '                       <div class="title textOver">'+ v['activity_info_classify_name'] +'</div>' +
                    '                       <div class="title2">'+v.activity_info_description +'</div>' +
                    '                       <div class="title3">'+ v.activity_info_day_label+'</div>' +
                    '                   </div>' +
                    '               </div>'
            })
            $("#inner").html(html);
            layer.close(page.loading);
        }
    }
});
